﻿//********************************************************************************//
//创建日期：<创建日期，2010-08-02>
//创建作者：<王一飞，wangyifei@shanghai3h.com>
//功能说明：YS_ZW_YINHANGPLDLHTH实体层次
//********************************************************************************//

#region Entity

using System;
using System.Data;
using Entity;
using Oracle.DataAccess.Client;
using Platform.Configuration;
using Platform.Data;

namespace Entity
{
    [Serializable]
    public class YS_ZW_YINHANGPLDLHTH
    {
        private decimal? m_dec_i_jlzt;

        private decimal? m_dec_i_nianyue;

        private decimal m_dec_id;

        private string m_str_s_beiyong1;

        private string m_str_s_beiyong2;

        private string m_str_s_beizhu;

        private string m_str_s_hetongh;

        private string m_str_s_huming;

        private string m_str_s_kaihuh;

        private string m_str_s_yinhang;

        private string m_str_s_yonghuh;

        private string m_str_s_zhanghao;

        private string m_str_s_zhifuhh;

        /// <summary>
        /// </summary>
        public decimal ID
        {
            get { return m_dec_id; }
            set { m_dec_id = value; }
        }

        /// <summary>
        /// </summary>
        public string S_YONGHUH
        {
            get { return m_str_s_yonghuh; }
            set { m_str_s_yonghuh = value; }
        }

        /// <summary>
        /// </summary>
        public string S_ZHANGHAO
        {
            get { return m_str_s_zhanghao; }
            set { m_str_s_zhanghao = value; }
        }

        /// <summary>
        /// </summary>
        public string S_HUMING
        {
            get { return m_str_s_huming; }
            set { m_str_s_huming = value; }
        }

        /// <summary>
        /// </summary>
        public string S_KAIHUH
        {
            get { return m_str_s_kaihuh; }
            set { m_str_s_kaihuh = value; }
        }

        /// <summary>
        /// </summary>
        public string S_YINHANG
        {
            get { return m_str_s_yinhang; }
            set { m_str_s_yinhang = value; }
        }

        /// <summary>
        /// </summary>
        public string S_ZHIFUHH
        {
            get { return m_str_s_zhifuhh; }
            set { m_str_s_zhifuhh = value; }
        }

        /// <summary>
        /// </summary>
        public string S_HETONGH
        {
            get { return m_str_s_hetongh; }
            set { m_str_s_hetongh = value; }
        }

        /// <summary>
        /// </summary>
        public decimal? I_NIANYUE
        {
            get { return m_dec_i_nianyue; }
            set { m_dec_i_nianyue = value; }
        }

        /// <summary>
        /// </summary>
        public decimal? I_JLZT
        {
            get { return m_dec_i_jlzt; }
            set { m_dec_i_jlzt = value; }
        }

        /// <summary>
        /// </summary>
        public string S_BEIZHU
        {
            get { return m_str_s_beizhu; }
            set { m_str_s_beizhu = value; }
        }

        /// <summary>
        /// </summary>
        public string S_BEIYONG1
        {
            get { return m_str_s_beiyong1; }
            set { m_str_s_beiyong1 = value; }
        }

        /// <summary>
        /// </summary>
        public string S_BEIYONG2
        {
            get { return m_str_s_beiyong2; }
            set { m_str_s_beiyong2 = value; }
        }
    }
}

#endregion

#region EntityProcess

namespace BLL.Access
{
    //using System.Data.OracleClient;

    public class YS_ZW_YINHANGPLDLHTHProcess
    {
        #region Field

        protected string conn;

        #endregion

        #region Construction

        public YS_ZW_YINHANGPLDLHTHProcess()
        {
            conn = ConfigHelper.PlatformConnString;
        }

        #endregion

        #region public

        /// <summary>
        ///     根据YS_ZW_YINHANGPLDLHTH实体添加或者修改YS_ZW_YINHANGPLDLHTH信息
        /// </summary>
        public bool InsertOrUpdate(YS_ZW_YINHANGPLDLHTH YS_ZW_YINHANGPLDLHTH, OracleTransaction Transaction)
        {
            if (YS_ZW_YINHANGPLDLHTH.ID == 0)
                InsertYS_ZW_YINHANGPLDLHTH(YS_ZW_YINHANGPLDLHTH, Transaction);
            else
                UpdateYS_ZW_YINHANGPLDLHTH(YS_ZW_YINHANGPLDLHTH, Transaction);
            return YS_ZW_YINHANGPLDLHTH.ID == 0 ? false : true;
        }

        /// <summary>
        ///     根据YS_ZW_YINHANGPLDLHTH实体添加或修改YS_ZW_YINHANGPLDLHTH信息
        /// </summary>
        public bool InsertOrUpdate(YS_ZW_YINHANGPLDLHTH YS_ZW_YINHANGPLDLHTH)
        {
            return InsertOrUpdate(YS_ZW_YINHANGPLDLHTH, null);
        }


        /// <summary>
        ///     根据YS_ZW_YINHANGPLDLHTH主键删除YS_ZW_YINHANGPLDLHTH信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteYS_ZW_YINHANGPLDLHTH(decimal ID, OracleTransaction Transaction)
        {
            var spName = "CS_DelYS_ZW_YINHANGPLDLHTH";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            var result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery(Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        ///     根据YS_ZW_YINHANGPLDLHTH主键删除YS_ZW_YINHANGPLDLHTH信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteYS_ZW_YINHANGPLDLHTH(decimal ID)
        {
            return DeleteYS_ZW_YINHANGPLDLHTH(ID, null);
        }

        /// <summary>
        ///     根据条件删除YS_ZW_YINHANGPLDLHTH信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteYS_ZW_YINHANGPLDLHTHsDynamic(string WhereClause, OracleTransaction Transaction)
        {
            var spName = "CS_DelYS_ZW_YINHANGPLDLHTHsDyn";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WhereClause;
            var result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery(Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        ///     根据条件删除YS_ZW_YINHANGPLDLHTH信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteYS_ZW_YINHANGPLDLHTHsDynamic(string WhereClause)
        {
            return DeleteYS_ZW_YINHANGPLDLHTHsDynamic(WhereClause, null);
        }

        /// <summary>
        ///     根据YS_ZW_YINHANGPLDLHTH主键选择YS_ZW_YINHANGPLDLHTH信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>YS_ZW_YINHANGPLDLHTH信息</returns>
        public YS_ZW_YINHANGPLDLHTH SelectYS_ZW_YINHANGPLDLHTH(decimal ID, OracleTransaction Transaction)
        {
            var spName = "CS_SelYS_ZW_YINHANGPLDLHTH";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            OracleDataReader rd;
            if (Transaction == null)
                rd = OracleHelper.ExecuteReader(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                rd = OracleHelper.ExecuteReader(Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (rd.Read())
            {
                var YS_ZW_YINHANGPLDLHTH = PopulateYS_ZW_YINHANGPLDLHTH(rd);
                rd.Close();
                return YS_ZW_YINHANGPLDLHTH;
            }
            return null;
        }

        /// <summary>
        ///     根据YS_ZW_YINHANGPLDLHTH主键选择YS_ZW_YINHANGPLDLHTH信息
        /// </summary>
        /// <returns>YS_ZW_YINHANGPLDLHTH信息</returns>
        public YS_ZW_YINHANGPLDLHTH SelectYS_ZW_YINHANGPLDLHTH(decimal ID)
        {
            return SelectYS_ZW_YINHANGPLDLHTH(ID, null);
        }

        /// <summary>
        ///     选择所有YS_ZW_YINHANGPLDLHTH信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>所有YS_ZW_YINHANGPLDLHTH信息</returns>
        public DataTable SelectYS_ZW_YINHANGPLDLHTHsAll(OracleTransaction Transaction)
        {
            var spName = "CS_SelYS_ZW_YINHANGPLDLHTHsAll";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset(Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            return null;
        }

        /// <summary>
        ///     选择所有YS_ZW_YINHANGPLDLHTH信息
        /// </summary>
        /// <returns>所有YS_ZW_YINHANGPLDLHTH信息</returns>
        public DataTable SelectYS_ZW_YINHANGPLDLHTHsAll()
        {
            return SelectYS_ZW_YINHANGPLDLHTHsAll(null);
        }

        /// <summary>
        ///     根据条件选择YS_ZW_YINHANGPLDLHTH信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>YS_ZW_YINHANGPLDLHTH信息</returns>
        public DataTable SelectYS_ZW_YINHANGPLDLHTHsDynamic(string WhereClause, string OrderByExpression,
            OracleTransaction Transaction)
        {
            var spName = "CS_SelYS_ZW_YINHANGPLDLHTHsDyn";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset(Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            return null;
        }


        /// <summary>
        ///     根据条件选择YS_ZW_YINHANGPLDLHTH信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <returns>YS_ZW_YINHANGPLDLHTH信息</returns>
        public DataTable SelectYS_ZW_YINHANGPLDLHTHsDynamic(string WhereClause, string OrderByExpression)
        {
            return SelectYS_ZW_YINHANGPLDLHTHsDynamic(WhereClause, OrderByExpression, null);
        }


        /// <summary>
        ///     根据条件选择YS_ZW_YINHANGPLDLHTH信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>YS_ZW_YINHANGPLDLHTH信息</returns>
        public DataTable SelectYS_ZW_YINHANGPLDLHTHsDynamic(string WhereClause, string OrderByExpression, int PageIndex,
            int PageSize, OracleTransaction Transaction)
        {
            var spName = "CS_SelYS_ZW_YINHANGPLDLHTHsDynPaged";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            storedParams[2].Value = PageIndex;
            storedParams[3].Value = PageSize;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset(Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            return null;
        }


        /// <summary>
        ///     根据条件选择YS_ZW_YINHANGPLDLHTH信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <returns>YS_ZW_YINHANGPLDLHTH信息</returns>
        public DataTable SelectYS_ZW_YINHANGPLDLHTHsDynamic(string WhereClause, string OrderByExpression, int PageIndex,
            int PageSize)
        {
            return SelectYS_ZW_YINHANGPLDLHTHsDynamic(WhereClause, OrderByExpression, PageIndex, PageSize, null);
        }

        /// <summary>
        ///     根据条件更新YS_ZW_YINHANGPLDLHTH字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateYS_ZW_YINHANGPLDLHTHsDynamic(string UpdateValue, string WhereClause,
            OracleTransaction Transaction)
        {
            var result = 0;
            if (UpdateValue == "" || WhereClause == "")
                return 0;
            var spName = "CS_UpdYS_ZW_YINHANGPLDLHTHDyn";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            storedParams[0].Value = UpdateValue;
            storedParams[1].Value = WhereClause;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset(Transaction, CommandType.StoredProcedure, spName, storedParams);
            result = Convert.ToInt32(storedParams[2].Value);
            return result;
        }

        /// <summary>
        ///     根据条件更新YS_ZW_YINHANGPLDLHTH字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateYS_ZW_YINHANGPLDLHTHsDynamic(string UpdateValue, string WhereClause)
        {
            return UpdateYS_ZW_YINHANGPLDLHTHsDynamic(UpdateValue, WhereClause, null);
        }

        #endregion

        #region Private

        private int InsertYS_ZW_YINHANGPLDLHTH(YS_ZW_YINHANGPLDLHTH YS_ZW_YINHANGPLDLHTH, OracleTransaction Transaction)
        {
            var spName = "CS_InsYS_ZW_YINHANGPLDLHTH";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = YS_ZW_YINHANGPLDLHTH.S_YONGHUH;
            storedParams[1].Value = YS_ZW_YINHANGPLDLHTH.S_ZHANGHAO;
            storedParams[2].Value = YS_ZW_YINHANGPLDLHTH.S_HUMING;
            storedParams[3].Value = YS_ZW_YINHANGPLDLHTH.S_KAIHUH;
            storedParams[4].Value = YS_ZW_YINHANGPLDLHTH.S_YINHANG;
            storedParams[5].Value = YS_ZW_YINHANGPLDLHTH.S_ZHIFUHH;
            storedParams[6].Value = YS_ZW_YINHANGPLDLHTH.S_HETONGH;
            storedParams[7].Value = YS_ZW_YINHANGPLDLHTH.I_NIANYUE;
            storedParams[8].Value = YS_ZW_YINHANGPLDLHTH.I_JLZT;
            storedParams[9].Value = YS_ZW_YINHANGPLDLHTH.S_BEIZHU;
            storedParams[10].Value = YS_ZW_YINHANGPLDLHTH.S_BEIYONG1;
            storedParams[11].Value = YS_ZW_YINHANGPLDLHTH.S_BEIYONG2;
            var result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery(Transaction, CommandType.StoredProcedure, spName, storedParams);
            YS_ZW_YINHANGPLDLHTH.ID = Convert.ToInt32(storedParams[12].Value);
            return result;
        }

        private bool UpdateYS_ZW_YINHANGPLDLHTH(YS_ZW_YINHANGPLDLHTH YS_ZW_YINHANGPLDLHTH,
            OracleTransaction Transaction)
        {
            var spName = "CS_UpdYS_ZW_YINHANGPLDLHTH";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = YS_ZW_YINHANGPLDLHTH.S_YONGHUH;
            storedParams[1].Value = YS_ZW_YINHANGPLDLHTH.S_ZHANGHAO;
            storedParams[2].Value = YS_ZW_YINHANGPLDLHTH.S_HUMING;
            storedParams[3].Value = YS_ZW_YINHANGPLDLHTH.S_KAIHUH;
            storedParams[4].Value = YS_ZW_YINHANGPLDLHTH.S_YINHANG;
            storedParams[5].Value = YS_ZW_YINHANGPLDLHTH.S_ZHIFUHH;
            storedParams[6].Value = YS_ZW_YINHANGPLDLHTH.S_HETONGH;
            storedParams[7].Value = YS_ZW_YINHANGPLDLHTH.I_NIANYUE;
            storedParams[8].Value = YS_ZW_YINHANGPLDLHTH.I_JLZT;
            storedParams[9].Value = YS_ZW_YINHANGPLDLHTH.S_BEIZHU;
            storedParams[10].Value = YS_ZW_YINHANGPLDLHTH.S_BEIYONG1;
            storedParams[11].Value = YS_ZW_YINHANGPLDLHTH.S_BEIYONG2;
            storedParams[12].Value = YS_ZW_YINHANGPLDLHTH.ID;
            var result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery(Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }


        private YS_ZW_YINHANGPLDLHTH PopulateYS_ZW_YINHANGPLDLHTH(IDataReader dr)
        {
            var YS_ZW_YINHANGPLDLHTH = new YS_ZW_YINHANGPLDLHTH();
            YS_ZW_YINHANGPLDLHTH.ID = dr["ID"] == DBNull.Value ? 0 : (decimal) dr["ID"];
            YS_ZW_YINHANGPLDLHTH.S_YONGHUH = dr["S_YONGHUH"] == DBNull.Value ? null : (string) dr["S_YONGHUH"];
            YS_ZW_YINHANGPLDLHTH.S_ZHANGHAO = dr["S_ZHANGHAO"] == DBNull.Value ? null : (string) dr["S_ZHANGHAO"];
            YS_ZW_YINHANGPLDLHTH.S_HUMING = dr["S_HUMING"] == DBNull.Value ? null : (string) dr["S_HUMING"];
            YS_ZW_YINHANGPLDLHTH.S_KAIHUH = dr["S_KAIHUH"] == DBNull.Value ? null : (string) dr["S_KAIHUH"];
            YS_ZW_YINHANGPLDLHTH.S_YINHANG = dr["S_YINHANG"] == DBNull.Value ? null : (string) dr["S_YINHANG"];
            YS_ZW_YINHANGPLDLHTH.S_ZHIFUHH = dr["S_ZHIFUHH"] == DBNull.Value ? null : (string) dr["S_ZHIFUHH"];
            YS_ZW_YINHANGPLDLHTH.S_HETONGH = dr["S_HETONGH"] == DBNull.Value ? null : (string) dr["S_HETONGH"];
            YS_ZW_YINHANGPLDLHTH.I_NIANYUE = dr["I_NIANYUE"] == DBNull.Value ? null : (decimal?) dr["I_NIANYUE"];
            YS_ZW_YINHANGPLDLHTH.I_JLZT = dr["I_JLZT"] == DBNull.Value ? null : (decimal?) dr["I_JLZT"];
            YS_ZW_YINHANGPLDLHTH.S_BEIZHU = dr["S_BEIZHU"] == DBNull.Value ? null : (string) dr["S_BEIZHU"];
            YS_ZW_YINHANGPLDLHTH.S_BEIYONG1 = dr["S_BEIYONG1"] == DBNull.Value ? null : (string) dr["S_BEIYONG1"];
            YS_ZW_YINHANGPLDLHTH.S_BEIYONG2 = dr["S_BEIYONG2"] == DBNull.Value ? null : (string) dr["S_BEIYONG2"];
            return YS_ZW_YINHANGPLDLHTH;
        }


        private void AddRowNumber(DataTable dt)
        {
            dt.Columns.Add(new DataColumn("RowNumber", typeof(int)));
            for (var i = 0; i < dt.Rows.Count; i++)
                dt.Rows[i][dt.Columns.Count - 1] = i + 1;
        }

        #endregion
    }
}

#endregion